{%- set cf_interfaces_list = device_info['configured_interfaces_info']['config_parsed']['configuration']['interfaces']['interface'] %}
{%- set rt_interfaces_list = device_info['runtime_interfaces_info']['parsed_output']['interface-information']['physical-interface'] %}
{%- if cf_interfaces_list is mapping %}
{%-     set cf_interfaces_list = [cf_interfaces_list] %}
{%- endif %}
{%- if rt_interfaces_list is mapping %}
{%-     set rt_interfaces_list = [rt_interfaces_list] %}
{%- endif %}
{%- set rt_interfaces_payloads = [] %}
{%- for phy_interface in rt_interfaces_list or [] %}
{%-     if phy_interface.name | regex_search('^em|^vme') %}
{%-         set physical_interface_mac_address = phy_interface.get('current-physical-address') %}
{%-         if 'logical-interface' in phy_interface %}
{%-             if phy_interface['logical-interface'] is mapping %}
{%-                 set log_units = [phy_interface['logical-interface']] %}
{%-             else %}
{%-                 set log_units = phy_interface['logical-interface'] %}
{%-             endif %}
{%-             for log_unit in log_units %}
{%-                 set add_fmly = log_unit.get('address-family') %}
{%-                 if add_fmly %}
{%-                     if not(add_fmly is mapping) %}
{%-                         set add_fmly = add_fmly[0] %}
{%-                     endif %}
{%-                     set inf_addr = add_fmly.get('interface-address') %}
{%-                     if inf_addr %}
{%-                         if not(inf_addr is mapping) %}
{%-                             set inf_addr = inf_addr[0] %}
{%-                         endif %}
{%-                         set addr_local = inf_addr.get('ifa-local') %}
{%-                         set addr_dest = inf_addr.get('ifa-destination') %}
{%-                         if addr_local %}
{%-                             set log_interface_payload = {
                                    "physical_interface_name": phy_interface.name,
                                    "physical_interface_mac_address": physical_interface_mac_address,
                                    "logical_interface_name": log_unit.name,
                                    "logical_interface_address": addr_local,
                                    "logical_interface_network": addr_dest
                                } %}
{%-                             set x=rt_interfaces_payloads.append(log_interface_payload) %}
{%-                         endif %}
{%-                     endif %}
{%-                 endif %}
{%-             endfor %}
{%-         endif %}
{%-     endif %}
{%- endfor %}
{
  "runtime_interfaces": {{rt_interfaces_payloads}}
}
